import { getMessageListData } from '@/services/api';

export default {
  namespace: 'message',

  state: {
    newslist: [] || '暂无数据',
  },

  effects: {
    *getMessageData({ payload }, { call, put }) {
      // console.log("payload",payload)
      const res = yield call(getMessageListData, payload);
      if (res) {
        yield put({ type: 'getMessageReducers', payload: res });
        console.log('获取消息列表:', res);
      } else {
        yield put({ type: 'getMessageReducers', payload: [] });
      }
    },
  },

  reducers: {
    getMessageReducers(state, { payload }) {
      console.log('payload', payload);
      return {
        ...state,
        newslist: { ...payload },
      };
    },
  },
};
